<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
 Copyright 2010 Yu Jianrong, All Rights Reserved
 
 Licensed under BSD License.
-->
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <script type="text/javascript" charset="UTF-8" src="/js/mootools-1.2.4-core-yc.js" ></script>
        <script type="text/javascript" charset="UTF-8" src="/js/Utilities.js" ></script>
        <title>Localization setting check</title>
<script type="text/javascript">


function Init()
{
    $("Btn_GetLang").addEvent('click', function()
    {
        $$(".tr_item").dispose();
        lang = $("langSelect").options[$("langSelect").selectedIndex].value;
        var theRequest = new Request({ "url": '/?getLocData='+lang, method: 'get', async: false, onSuccess:function(responseText, responseXML) { resultObj=JSON.decode(responseText); } });
        theRequest.send();

        var odd=true;
        $each(resultObj , function(value)
        {
            var tr=new Element("tr",{class:'tr_item',style:odd?'background-color:#eee':''});
                tr.appendChild(new Element("td",{'value':value.tag, class:'loc_tag' ,text:value.tag}));
                tr.appendChild(new Element("td",{text:value.en, style:'width:400px'}));
                tr.appendChild(new Element("td",{html:"<input type='text' class='loc_trans' style='width:600px"+(odd?';background-color:#f7f7f7':'') +"' "+(value.loc?"value='"+value.loc+"' ":"")+"/>"}));
                $("Lang_List").appendChild(tr);
            odd = odd == false;
        });
        $("Btn_Generate").disabled=false;
    });
    $("Btn_Generate").addEvent('click', function()
    {
        var Pycode="#!/usr/bin/env python\n# vim: set fileencoding=utf8\n#\n# Copyright 2010 Yu Jianrong, All Rights Reserved\n#\n# Licensed under BSD License.\n#\n";
        Pycode+="# Language: " + lang + "\n";
        Pycode+="LocData= {\n";
        $$(".tr_item").each(function(trObj)
        {
            if (trObj.getElement('.loc_trans').value.trim()=="")
                return;
            Pycode+="  '"+trObj.getElement('.loc_tag').value+"':'" + trObj.getElement('.loc_trans').value+"',\n"
        });
        Pycode+="}\n";

        $("Txt_Pycode").value=Pycode;
    });
}
window.addEvent('domready', Init);
</script>
    </head>

    <body>
        Localization setting check <br/>

        <select id="langSelect">
            <option value="zh_CN">Chinese Simplified</option>
            <option value="zh_TW">Chinese Tranditional</option>
        </select>
        <input type="button" value="Get LanguageData" id="Btn_GetLang"/><br/>
        
        <table border='1' id='Lang_List' style="font-size:smaller;border-collapse:collapse;"  frame='box'>
            <tr style='background-color:#ccf'>
                <th>Loc_ID</th>
                <th style='width:400px'>English</th>
                <th>Loclized</th>
            </tr>
        </table>
        <br/>
        <input type="button" value="Generate py code" id="Btn_Generate" disabled="disabled" /><br/>
        <textarea id="Txt_Pycode" rows="20" cols="90" ></textarea><br/>
    </body>
</html>
<!--
    vim:ts=4:ft=htmlos
-->



